package com.xinchuang.controller.targetSystem;

import com.alibaba.fastjson.JSONObject;
import com.xinchuang.common.Result;
import com.xinchuang.entity.targetSystem.target.SystemType;
import com.xinchuang.service.targetSystem.SysElseService;
import com.xinchuang.service.targetSystem.SystemTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName ElseController
 * @Description: TODO(写一段描述的话)
 * @Author zhangxuan
 * @Date 2022-03-23 17:27
 * @Verion V1.0
 */
@Api(value = "新版", tags = {"新版"})
@RestController
@RequestMapping(value = "/else")
public class ElseController {

    /**
     * 系统体系类型操作
     */
    private final String SYSTEM_TYPE = "/systemType";

    /**
     * 系统体系类型下拉
     */
    private final String SYSTEM_TYPE_PUT = "/systemTypePut";

    /**
     * 查询目标类型下拉
     */
    private final String TARGET_TYPE_PUT = "/targetTypePut";

    /**
     * 系统/体系坐标其他信息处理
     */
    private final String ADD_SYSTEM_POSITION = "/sysPosition";

    @Autowired
    private SystemTypeService systemTypeService;

    @Autowired
    private SysElseService sysElseService;

    @PostMapping(SYSTEM_TYPE)
    @ApiOperation(value = "新增系统体系类型")
    public Result addSystemType(
            @RequestBody SystemType systemType
    ) {
        return systemTypeService.addOrUpdateSystemType(systemType);
    }

    @ApiOperation(value = "修改系统体系类型")
    @PutMapping(SYSTEM_TYPE)
    public Result updateSystemType(
            @RequestBody SystemType systemType
    ) {
        return systemTypeService.addOrUpdateSystemType(systemType);
    }

    @ApiOperation(value = "删除系统体系类型")
    @DeleteMapping(SYSTEM_TYPE)
    public Result deleteSystemType(
            @RequestParam("id") String id
    ) {
        return systemTypeService.deleteSystemType(id);
    }

    @ApiOperation(value = "查询系统体系类型")
    @GetMapping(SYSTEM_TYPE)
    public Result getSystemType(
            @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
            @RequestParam(value = "status", defaultValue = "1") Integer status
    ) {
        return systemTypeService.selectSystemType(pageNum, pageSize, status);
    }

    @ApiOperation(value = "系统体系类型下拉")
    @GetMapping(SYSTEM_TYPE_PUT)
    public Result putSystemType(
            @RequestParam(value = "status", defaultValue = "1") Integer status
    ) {
        return systemTypeService.selectSystemTypePut(status);
    }

    @ApiOperation(value = "查询目标类型下拉")
    @GetMapping(TARGET_TYPE_PUT)
    public Result putTargetType(
    ) {
        return systemTypeService.selectTargetTypePut();
    }

    @ApiOperation(value = "新增系统/体系坐标其他信息处理")
    @PostMapping(ADD_SYSTEM_POSITION)
    public Result addPosition(
            @RequestBody JSONObject json
            ) {
        return sysElseService.addPosition(json);
    }

    @ApiOperation(value = "获取系统/体系坐标其他信息处理")
    @GetMapping(ADD_SYSTEM_POSITION)
    public Result getPosition(
            @RequestParam(value = "id") String id
    ) {
        return sysElseService.getPosition(id);
    }

}